package com.museum.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.museum.entity.Exhibition;
import com.museum.mapper.ExhibitionMapper;
import com.museum.service.ExhibitionService;
import org.springframework.stereotype.Service;

@Service
public class ExhibitionServiceImpl extends ServiceImpl<ExhibitionMapper, Exhibition> implements ExhibitionService {

    @Override
    public Page<Exhibition> pageList(Page<Exhibition> page, Integer status) {
        LambdaQueryWrapper<Exhibition> wrapper = new LambdaQueryWrapper<>();
        if (status != null) {
            wrapper.eq(Exhibition::getStatus, status);
        }
        wrapper.orderByDesc(Exhibition::getCreateTime);
        return page(page, wrapper);
    }
    
    @Override
    public boolean updateStatus(Long id, Integer status) {
        Exhibition exhibition = getById(id);
        if (exhibition == null) {
            return false;
        }
        exhibition.setStatus(status);
        return updateById(exhibition);
    }
} 